home *** CD-ROM | disk | FTP | other *** search
- #include <graphics.h>
-
- main()
- {
- int graphdriver = DETECT, graphmode;
-
- /* Detect and initialize graphics system */
- initgraph(&graphdriver, &graphmode, "c:\\turboc");
- outtextxy(10,10, "Demonstration of setviewport with 2 viewports");
- /* Set current color to red */
- setcolor(RED);
- /* Dashed lines for boundaries */
- setlinestyle(USERBIT_LINE, 0xf0f, NORM_WIDTH);
- /* Set a 200 x 200 viewport */
- setviewport(0,100, 200, 300, 1);
- /* Show boundary of viewport */
- rectangle(0,0,200,200);
- /* Now draw a pieslice, remember the coordinates of
- * the center are specified in viewport coordinates
- * with the origin at upper left corner of viewport.
- */
- setfillstyle(SOLID_FILL, YELLOW);
- pieslice(150, 150, 0, 360, 100);
- /* Now set another viewport, and redraw same slice */
- /* This is a 150 x 150 viewport */
- setviewport(240,100,390,250,1);
- /* Again show boundary of the viewport */
- rectangle(0,0,150,150);
- setfillstyle(SLASH_FILL, YELLOW);
- /* Draw the same ellipse again. */
- pieslice(150, 150, 0, 360, 100);
-
- /* Exit graphics mode when user strikes any key */
- outtextxy(10, getmaxy() - 50, "Press any key to exit");
- getch(); /* A do-nothing read */
- closegraph();
- }